package fr.aprr.geoloc.server.dao;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import fr.aprr.geoloc.shared.domain.Odyssee;

@Repository
public class OdysseeDao {

	@PersistenceContext
    private EntityManager entityManager;
	
	@Transactional
	public Odyssee getOdyssee(Integer i) {
		return entityManager.find(Odyssee.class, i);
	}


	@Transactional
	@SuppressWarnings("unchecked")
	public List<Odyssee> getAllOdyssee() {
		List<Odyssee> odyssee = entityManager.createQuery("from Odyssee").getResultList();
		return odyssee;
	}
	
}
